package com.sky.mapper;

import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
    /**
     * 菜品分页查询
     */
    List<DishVO> selectAll(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 新增菜品
     */
    void insert(Dish dish);

    /**
     * 批量删除菜品
     */
    void deleteBatch(Long[] ids);

    /**
     * 根据id查询菜品
     */
    @Select("select d.*,c.name as categoryName from dish d left outer join sky_take_out.category c on d.category_id = c.id where d.id = #{id}")
    Dish getById(Long id);

    /**
     * 修改菜品
     */
    void update(Dish dish);

    /**
     * 根据分类id查询菜品
     */
    @Select("select * from dish where category_id = #{categoryId}")
    List<DishVO> list(Long categoryId);

    /**
     * 根据分类id和状态查询菜品
     */
    List<Dish> listWithStatus(Dish dish);

    /**
     * 根据条件统计菜品数量
     */
    Integer countByMap(Map map);
}
